/**
* All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
*
* MpmProjectServiceAuto
* 项目立项
*
* 修改纪录
* 2020-12-25 版本：1.0 lanjianwei 创建。
* @version 版本：1.0
* @author 作者：lanjianwei
* 创建日期：2020-12-25
*/

package com.topscomm.mpm.service.impl.auto;

import javax.annotation.Resource;
import com.topscomm.basic.IBasicDao;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.tap.common.DatacodeCache;

import java.text.DecimalFormat;
import java.util.Map;
import com.topscomm.mpm.*;
import com.topscomm.mpm.pojo.MpmProjectEntity;
import com.topscomm.mpm.dao.IMpmProjectDao;


public class MpmProjectServiceAuto extends MpmService<MpmProjectEntity,IMpmProjectDao> {

	/**
	 * @author: lanjianwei
	 * @date: 2020-12-25
	 * @param mapRow
	 * @description:设置字段显示值
	 * @modify:
	 */
	@Override
	public void setDispFields(Map<String, Object> mapRow, DatacodeCache datacodeCache) {
		String temp;
		if (mapRow.get("flowid") != null) {
			temp = mapRow.get("flowid").toString();
			mapRow.put("dispflowid", datacodeCache.getValueDynamic("ApprovalFlow_MpmProject", temp, "id", "name"));
		}
		if (mapRow.get("state") != null) {
			temp = mapRow.get("state").toString();
			mapRow.put("dispstate", datacodeCache.getValueDynamic("TapApprovalBillState", temp, "code", "name"));
		}
		if (mapRow.get("enabled") != null) {
			temp = mapRow.get("enabled").toString();
			mapRow.put("dispenabled", datacodeCache.getValueDynamic("CboYesNo", temp, "code", "name"));
		}
		if (mapRow.get("projectlevel") != null) {
			temp = mapRow.get("projectlevel").toString();
			mapRow.put("dispprojectlevel", datacodeCache.getValueDynamic("MpmProjectLevel", temp, "code", "name"));
		}
		if (mapRow.get("approvaltype") != null) {
			temp = mapRow.get("approvaltype").toString();
			mapRow.put("dispapprovaltype", datacodeCache.getValueDynamic("MpmApprovalType", temp, "code", "name"));
		}
		if (mapRow.get("projectstate") != null) {
			temp = mapRow.get("projectstate").toString();
			mapRow.put("dispprojectstate", datacodeCache.getValueDynamic("MpmProjectState", temp, "code", "name"));
		}
		if (mapRow.get("abnormalstate") != null) {
			temp = mapRow.get("abnormalstate").toString();
			mapRow.put("dispabnormalstate", datacodeCache.getValueDynamic("MpmProjectAbnormalState", temp, "code", "name"));
		}
		// 处理手机端金额展示问题
		if (mapRow.get("projectmoney") != null) {
			temp = mapRow.get("projectmoney").toString();
			String str=new DecimalFormat("#,###.00").format(ConvertUtil.convertToDouble(temp));
			if (str.startsWith(".")){
				// 补零
				str = "0"+str;
			}
			mapRow.put("dispprojectmoney",str+"万元");
		}
		if (mapRow.get("projectendmoney") != null) {
			temp = mapRow.get("projectendmoney").toString();
			String str=new DecimalFormat("#,###.00").format(ConvertUtil.convertToDouble(temp));
			if (str.startsWith(".")){
				// 补零
				str = "0"+str;
			}
			mapRow.put("dispprojectendmoney", str+"万元");
		}
		if (mapRow.get("participatemoney") != null) {
			temp = mapRow.get("participatemoney").toString();
			mapRow.put("dispparticipatemoney",temp+"万元");
		}
	}

	@Override
	@Resource(name = "mpmProjectDao")
	public void setDao(IBasicDao<MpmProjectEntity> dao) {
		super.setDao(dao);
	}
}
